<!--  -->
<template>
  <div>
    <List :list="searchList" />
  </div>
</template>

<script>
import List from "./home/List";
export default {
  data() {
    return {
      searchList: [],
    };
  },

  components: {
    List,
  },
  watch: {
    $route: {
      handler() {
        this.queryinfo = this.$route.query.queryinfo;
        this.getSearchList();
      },
      deep: true,
    },
  },
  created() {
    this.queryinfo = this.$route.query.queryinfo;
    this.getSearchList();
  },
  methods: {
    async getSearchList() {
      const { data: res } = await this.$http.get(
        `/dqxmall/prosysproinfo/getAllShopByCatalogId?key=${this.queryinfo}`
      );
      this.searchList = [];
      if (res.code === 0) {
        // this.searchList = res.page.list;
        res.page.list.forEach((item) => {
          if (item.publishStatus) {
            var data = {};
            data.id = item.id;
            data.catalogId = item.catalogId;
            data.saleCount = 0;
            item.skus.forEach((item1) => {
              data.saleCount += item1.saleCount;
            });
            data.imgSrc = item.images[0];
            data.proName = item.proName;
            data.price = item.price;
            this.searchList.push(data);
          }
        });
        // this.$store.dispatch("setSearchList", this.searchList);
      }
    },
  },
};
</script>
<style lang="less" scoped></style>
